package com.itheima;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

public class Demo1 implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        String username = servletRequest.getParameter("username");
        String password = servletRequest.getParameter("password");
        servletResponse.setContentType("text/html;charset=UTF-8");
        if(username.equals("123")&&password.equals("123")){
            servletResponse.getWriter().write("登录成功");
        }else{
            PrintWriter writer = servletResponse.getWriter();
            writer.write("登录失败");
        }
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
